import React, { Component } from 'react';

import { Popconfirm, Button, message } from 'antd'
import { deleteAdmin } from '../../api/admin';

interface IProps {
    id: number
    deleteRole:(id:number)=>void
}

class DeleteRole extends Component<IProps> {
    // constructor(props:any,context:any) {
    //     super(props,context);
    //     this.state = {  };
    // }


    // confirm(e) {
    //     console.log(e);
    //     message.success('Click on Yes');
    // }

    // cancel(e) {
    //     console.log(e);
    //     message.error('Click on No');
    // }

    delteRole = () => {
        this.props.deleteRole(this.props.id)
        // delteRole(this.props.id).then(reponse => {
        //     const { code, msg } = reponse.data
        //     if (code === 0) {
        //         message.success(msg)
        //         this.props.deleteAdmin(this.props.id)
        //     }else{
        //         message.error(msg)
        //     }
        // })
    }

    cancel=()=>{
       message.info("取消删除！") 
    }


    render() {
        return (
            <>
                <Popconfirm
                    title="确定要删除权限吗？" 
                    onConfirm={this.delteRole}
                    onCancel={this.cancel}
                    okText="删除"
                    cancelText="取消"
                >
                    <Button type="primary" danger>删除</Button>
                </Popconfirm>
            </>
        );
    }
}

export default DeleteRole;